package rpc.loadbalance.loadbalancer;

import rpc.loadbalance.AbstractLoadBalance;
import rpc.remote.dto.RpcRequest;

import java.util.List;
import java.util.Random;

/**
 * @ClassName: RandomLoadBalance
 * @Description:
 * @author: Kowk
 * @since:1.0.0
 */
public class RandomLoadBalance extends AbstractLoadBalance {
    @Override
    protected String doSelect(List<String> serviceAddresses, RpcRequest request) {
        Random random = new Random();
        return serviceAddresses.get(random.nextInt(serviceAddresses.size()));
    }
}
